#include "GY_GraphicsCornerStyleRect.h"

GY_GraphicsCornerStyleRect::GY_GraphicsCornerStyleRect(const QString &guid, QGraphicsItem *parent)
    :GY_BasicsGraphicsObject(guid,this,parent)
{
    //图元类型
    GY_Object::setUserData(GY_ENUM::ClassType,QVariant("CornerStyleRect"));
    initializationPropertyInfo();
    QMap<QVariant,QPointF> editPoints = {
        {"Position",m_PropertyInfoMap["Position"].propertyValue.toPointF()},
        {"Size",m_PropertyInfoMap["Size"].propertyValue.toPointF()}
    };
    updateDraw();
    this->setPen(QColor(0,255,0));
}

GY_GraphicsCornerStyleRect::GY_GraphicsCornerStyleRect(const QString &guid,
                                                       const QPointF &positionPoint, const QPointF &sizePoint,
                                                       qreal cornerRadius, QGraphicsItem *parent)
    :GY_BasicsGraphicsObject(guid,this,parent)
{
    //图元类型
    GY_Object::setUserData(GY_ENUM::ClassType,QVariant("CornerStyleRect"));
    initializationPropertyInfo();
    m_PropertyInfoMap["Position"].propertyValue=positionPoint;
    m_PropertyInfoMap["Size"].propertyValue=sizePoint;
    m_PropertyInfoMap["CornerRadius"].propertyValue=cornerRadius;
    QMap<QVariant,QPointF> editPoints = {
        {"Position",m_PropertyInfoMap["Position"].propertyValue.toPointF()},
        {"Size",m_PropertyInfoMap["Size"].propertyValue.toPointF()}
    };
    updateDraw();
    this->setPen(QColor(0,255,0));
}

GY_GraphicsCornerStyleRect::~GY_GraphicsCornerStyleRect()
{

}

bool GY_GraphicsCornerStyleRect::updatePositionPoint(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    //获取鼠标坐标
    QPointF mousePoint = this->mapFromScene(value.value<QPointF>());
    m_PropertyInfoMap[name].propertyValue=mousePoint;
    //从map中取出相应数据
    QPointF positionPoint = m_PropertyInfoMap.value("Position").propertyValue.value<QPointF>();
    QPointF sizePoint = m_PropertyInfoMap.value("Size").propertyValue.value<QPointF>();
    //定义positionPoint与sizePoint之间的距离
    qreal width = sizePoint.x()-positionPoint.x();
    qreal height = sizePoint.y()-positionPoint.y();
    if(name.endsWith("Position"))
    {
        sizePoint.setX(mousePoint.x()+width);
        sizePoint.setY(mousePoint.y()+height);
        m_PropertyInfoMap["Size"].propertyValue=sizePoint;

        positionPoint=mousePoint;
        m_PropertyInfoMap["Position"].propertyValue=positionPoint;
    }
    updateDraw();
    this->setCenterPointF(positionPoint);
    return true;
}

bool GY_GraphicsCornerStyleRect::updateSizePoint(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    QPointF mousePoint = this->mapFromScene(value.value<QPointF>());
    m_PropertyInfoMap[name].propertyValue=mousePoint;
    QPointF sizePoint = m_PropertyInfoMap.value("Size").propertyValue.value<QPointF>();
    if(name.endsWith("Size"))
    {
        sizePoint.setX(mousePoint.x());
        sizePoint.setY(mousePoint.y());
        m_PropertyInfoMap["Size"].propertyValue=sizePoint;
    }
    updateDraw();
    this->setEditPointF(name,mousePoint);
    return true;
}

bool GY_GraphicsCornerStyleRect::updateCornerRadius(const QString &name, const QVariant &value)
{
    if(!value.canConvert<qreal>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updateDraw();
    return true;
}

bool GY_GraphicsCornerStyleRect::updateBottomLeftCornerStyle(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QString>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updateDraw();
    return true;
}

bool GY_GraphicsCornerStyleRect::updateTopLeftCornerStyle(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QString>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updateDraw();
    return true;
}

bool GY_GraphicsCornerStyleRect::updateTopRightCornerStyle(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QString>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updateDraw();
    return true;
}

bool GY_GraphicsCornerStyleRect::updateBottomRightCornerStyle(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QString>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value;
    updateDraw();
    return true;
}

void GY_GraphicsCornerStyleRect::updateBottomLeftCornerStylePath(const QPointF &sizePoint,const QPointF &positionPoint,  const qreal cornerRadius,const QString &cornerStyle,QPainterPath &path)
{
//    QPainterPath path;//width=100,height=50,positionPoint(0,0),sizePoint(100,50),cornerRadius=10
    //左下角
//    typedef enum CornerStyle BottomLeftCornerStyle;//定义枚举类型变量
//    QString cornerStyle = m_PropertyInfoMap["BottomLeftCornerStyle"].propertyValue.toString();
    CornerStyle BottomLeft = m_CornerStyleEnumToMap[m_PropertyInfoMap[cornerStyle].propertyValue.toString()];//为枚举成员传值
    //左下角
    switch (BottomLeft) {
        //左下角为反向圆角√
        case CornerStyle::INVERTED_ROUND:
            //左下反向圆角//p2(-10,-10)√
            path.arcTo(positionPoint.x()-cornerRadius,positionPoint.y()-cornerRadius,cornerRadius*2,cornerRadius*2,0.0f,-90.0f);
            break;
        //左下角为反向直角√
        case CornerStyle::INVERTED_SQUARE:
            //左下反向直角//p2'(10,10)    p2''(0,10)
            path.lineTo(positionPoint.x()+cornerRadius,positionPoint.y()+cornerRadius);
            path.lineTo(positionPoint.x(),positionPoint.y()+cornerRadius);
            break;
        //左下角为平角√
        case CornerStyle::MITER:
            //左下平角//p2(0,10)
            path.lineTo(positionPoint.x(),positionPoint.y()+cornerRadius);
            break;
        //左下角为圆角√
        case CornerStyle::ROUND:
            //左下圆角//p2(0,0)√
            path.arcTo(positionPoint.x(),positionPoint.y(),cornerRadius*2,cornerRadius*2,90.0f,90.0f);
            break;
        //左下角为直角√
        case CornerStyle::SQUARE:
            //左下直角//p2'(0,0)    p2''(0,10)
            path.lineTo(positionPoint.x(),positionPoint.y());
            path.lineTo(positionPoint.x(),positionPoint.y()+cornerRadius);
            break;
    }
//    this->setPath(path);//错误用法：会造成自动连线的后果导致绘图错误
}

void GY_GraphicsCornerStyleRect::updateTopLeftCornerStylePath(const QPointF &sizePoint, const QPointF &positionPoint, const qreal cornerRadius,const QString &cornerStyle,QPainterPath &path)
{
    //左上角
    typedef enum CornerStyle TopLeftCornerStyle;
    TopLeftCornerStyle TopLeft = m_CornerStyleEnumToMap[m_PropertyInfoMap[cornerStyle].propertyValue.toString()];
    //左上角
    switch (TopLeft) {
        //左上角为反向圆角√
        case TopLeftCornerStyle::INVERTED_ROUND:
            //左上反向圆角//p4(10,40)√
            path.arcTo(positionPoint.x()-cornerRadius,sizePoint.y()-cornerRadius,cornerRadius*2,cornerRadius*2,90.0f,-90.0f);
            break;
        //左上角为反向直角√
        case TopLeftCornerStyle::INVERTED_SQUARE:
            //左上反向直角//p4'(10,40)√    p4''(10,50)√
            path.lineTo(positionPoint.x()+cornerRadius,sizePoint.y()-cornerRadius);
            path.lineTo(positionPoint.x()+cornerRadius,sizePoint.y());
            break;
        //左上角为平角√
        case TopLeftCornerStyle::MITER:
            //左上平角//p4(10,50)√
            path.lineTo(positionPoint.x()+cornerRadius,sizePoint.y());
            break;
        //左上角为圆角√
        case TopLeftCornerStyle::ROUND:
            //左上圆角//p4(0,50)√
            path.arcTo(positionPoint.x(),sizePoint.y()-cornerRadius*2,cornerRadius*2,cornerRadius*2,180.0f,90.0f);
            break;
        //左上角为直角√
        case TopLeftCornerStyle::SQUARE:
            //左上直角//p4'(0,50)√    p4''(10,50)√
            path.lineTo(positionPoint.x(),sizePoint.y());
            path.lineTo(positionPoint.x()+cornerRadius,sizePoint.y());
            break;
    }
//    this->setPath(path);//错误用法：会造成自动连线的后果导致绘图错误
}

void GY_GraphicsCornerStyleRect::updateTopRightCornerStylePath(const QPointF &sizePoint, const QPointF &positionPoint, const qreal cornerRadius,const QString &cornerStyle,QPainterPath &path)
{
    //右上角
    typedef enum CornerStyle TopRightCornerStyle;//
    TopRightCornerStyle TopRight = m_CornerStyleEnumToMap[m_PropertyInfoMap[cornerStyle].propertyValue.toString()];
    //右上角
    switch (TopRight) {
        //右上角为反向圆角//√
        case TopRightCornerStyle::INVERTED_ROUND:
            //右上反向圆角//p6(90,40)√
            path.arcTo(sizePoint.x()-cornerRadius,sizePoint.y()-cornerRadius,cornerRadius*2,cornerRadius*2,180.0f,-90.0f);
            break;
        //右上角为反向直角√
        case TopRightCornerStyle::INVERTED_SQUARE:
            //右上反向直角//p6'(90,40)√    p6''(100,40)√
            path.lineTo(sizePoint.x()-cornerRadius,sizePoint.y()-cornerRadius);
            path.lineTo(sizePoint.x(),sizePoint.y()-cornerRadius);
            break;
        //右上角为平角√
        case TopRightCornerStyle::MITER:
            //右上平角//p6(100,40)√
            path.lineTo(sizePoint.x(),sizePoint.y()-cornerRadius);
            break;
        //右上角为圆角√
        case TopRightCornerStyle::ROUND:
            //右上圆角//p6(80,30)√
            path.arcTo(sizePoint.x()-cornerRadius*2,sizePoint.y()-cornerRadius*2,cornerRadius*2,cornerRadius*2,270.0f,90.0f);
            break;
        //右上角为直角//√
        case TopRightCornerStyle::SQUARE:
            //右上直角//p6'(100,50)√    p6''(100,40)√
            path.lineTo(sizePoint.x(),sizePoint.y());
            path.lineTo(sizePoint.x(),sizePoint.y()-cornerRadius);
            break;
    }
//    this->setPath(path);//错误用法：会造成自动连线的后果导致绘图错误
}

void GY_GraphicsCornerStyleRect::updateBottomRightCornerStylePath(const QPointF &sizePoint, const QPointF &positionPoint, const qreal cornerRadius,const QString &cornerStyle,QPainterPath &path)
{
    //右下角
    typedef enum CornerStyle BottomRightCornerStyle;
    BottomRightCornerStyle BottomRight = m_CornerStyleEnumToMap[m_PropertyInfoMap[cornerStyle].propertyValue.toString()];
    //右下角
    switch (BottomRight) {
        //右下角为反向圆角√
        case BottomRightCornerStyle::INVERTED_ROUND:
            //右下反向圆角
            path.arcTo(sizePoint.x()-cornerRadius,positionPoint.y()-cornerRadius,cornerRadius*2,cornerRadius*2,-90.0f,-90.0f);
            break;
        //右下角为反向直角√
        case BottomRightCornerStyle::INVERTED_SQUARE:
            //右下反向直角
            path.lineTo(sizePoint.x()-cornerRadius,positionPoint.y()+cornerRadius);
            path.lineTo(sizePoint.x()-cornerRadius,positionPoint.y());
            break;
        //右下角为平角√
        case BottomRightCornerStyle::MITER:
            //右下平角
            path.lineTo(sizePoint.x()-cornerRadius,positionPoint.y());
            break;
        //右下角为圆角√
        case BottomRightCornerStyle::ROUND:
            //右下圆角
            path.arcTo(sizePoint.x()-cornerRadius*2,positionPoint.y(),cornerRadius*2,cornerRadius*2,0.0f,90.0f);
            break;
        //右下角为直角√
        case BottomRightCornerStyle::SQUARE:
            //右下直角
            path.lineTo(sizePoint.x(),positionPoint.y());
            path.lineTo(sizePoint.x()-cornerRadius,positionPoint.y());
            break;
    }
//    this->setPath(path);//错误用法：会造成自动连线的后果导致绘图错误
}


void GY_GraphicsCornerStyleRect::updateDraw()
{
    QPointF positionPoint = m_PropertyInfoMap.value("Position").propertyValue.toPointF();
    QPointF sizePoint = m_PropertyInfoMap.value("Size").propertyValue.toPointF();
    qreal radius = m_PropertyInfoMap.value("CornerRadius").propertyValue.value<qreal>();
    QString p_BottomLeftCornerStyle = m_PropertyInfoMap.value("BottomLeftCornerStyle").propertyValue.toString();
    QString p_TopLeftCornerStyle = m_PropertyInfoMap.value("TopLeftCornerStyle").propertyValue.toString();
    QString p_TopRightCornerStyle = m_PropertyInfoMap.value("TopRightCornerStyle").propertyValue.toString();
    QString p_BottomRightCornerStyle = m_PropertyInfoMap.value("BottomRightCornerStyle").propertyValue.toString();

    QString BottomLeftCornerStyle = p_BottomLeftCornerStyle;
    QString TopLeftCornerStyle = p_TopLeftCornerStyle;
    QString TopRightCornerStyle = p_TopRightCornerStyle;
    QString BottomRightCornerStyle = p_BottomRightCornerStyle;

    QPointF startPoint = sizePoint;//默认位于右上角
    QPointF endPoint = positionPoint;//默认位于左下角

    //若宽高的一半小于半径
    qreal width=qAbs(startPoint.x()-endPoint.x());
    qreal height=qAbs(startPoint.y()-endPoint.y());
    //若半径大于宽高的一半则取宽高的半值，否则取半径的值
    radius=radius>qMin(width,height)/2?qMin(width,height)/2:radius;

    QPainterPath path;//实例化一个绘制器类对象
    /*按不同选择情况更新绘制*/
    //若上边与下边、左边与右边不交换（sizePoint在相对于positionPoint的第一象限）
    if(positionPoint.x()<sizePoint.x()&&positionPoint.y()<sizePoint.y())
    {
        path.moveTo(endPoint.x()+radius,endPoint.y());//起点√
        updateBottomLeftCornerStylePath(startPoint,endPoint,radius,"BottomLeftCornerStyle",path);//左下角√
        path.lineTo(endPoint.x(),startPoint.y()-radius);//左边√
        updateTopLeftCornerStylePath(startPoint,endPoint,radius,"TopLeftCornerStyle",path);//左上角√
        path.lineTo(startPoint.x()-radius,startPoint.y());//上边√
        updateTopRightCornerStylePath(startPoint,endPoint,radius,"TopRightCornerStyle",path);//右上角√
        path.lineTo(startPoint.x(),endPoint.y()+radius);//右边√
        updateBottomRightCornerStylePath(startPoint,endPoint,radius,"BottomRightCornerStyle",path);//右下角√
        path.closeSubpath();//下边√
    }

    //若右边平移至左边之左（sizePoint在相对于positionPoint的第二象限）
    if (positionPoint.x()>sizePoint.x()&&positionPoint.y()<sizePoint.y())
    {
        startPoint=QPointF(positionPoint.x(),sizePoint.y());
        endPoint=QPointF(sizePoint.x(),positionPoint.y());

        BottomLeftCornerStyle = p_BottomRightCornerStyle;
        TopLeftCornerStyle = p_TopRightCornerStyle;
        TopRightCornerStyle = p_TopLeftCornerStyle;
        BottomRightCornerStyle = p_BottomLeftCornerStyle;

        path.moveTo(endPoint.x()+radius,endPoint.y());//起点√
        updateBottomLeftCornerStylePath(startPoint,endPoint,radius,"BottomRightCornerStyle",path);//左下角√

        path.lineTo(endPoint.x(),startPoint.y()-radius);//左边√
        updateTopLeftCornerStylePath(startPoint,endPoint,radius,"TopRightCornerStyle",path);//左上角√

        path.lineTo(startPoint.x()-radius,startPoint.y());//上边√
        updateTopRightCornerStylePath(startPoint,endPoint,radius,"TopLeftCornerStyle",path);//右上角√

        path.lineTo(startPoint.x(),endPoint.y()+radius);//右边√
        updateBottomRightCornerStylePath(startPoint,endPoint,radius,"BottomLeftCornerStyle",path);//右下角√

        path.closeSubpath();//下边√
    }
    //若上边平移至下边之下且右边平移至左边之左（sizePoint在相对于positionPoint的第三象限）
    else if (positionPoint.x()>sizePoint.x()&&positionPoint.y()>sizePoint.y())
    {
        startPoint=positionPoint;
        endPoint=sizePoint;

        BottomLeftCornerStyle = p_TopRightCornerStyle;
        TopLeftCornerStyle = p_BottomRightCornerStyle;
        TopRightCornerStyle = p_BottomLeftCornerStyle;
        BottomRightCornerStyle = p_TopLeftCornerStyle;

        path.moveTo(endPoint.x()+radius,endPoint.y());//起点√
        updateBottomLeftCornerStylePath(startPoint,endPoint,radius,"TopRightCornerStyle",path);//左下角√

        path.lineTo(endPoint.x(),startPoint.y()-radius);//左边√
        updateTopLeftCornerStylePath(startPoint,endPoint,radius,"BottomRightCornerStyle",path);//左上角√

        path.lineTo(startPoint.x()-radius,startPoint.y());//上边√
        updateTopRightCornerStylePath(startPoint,endPoint,radius,"BottomLeftCornerStyle",path);//右上角√

        path.lineTo(startPoint.x(),endPoint.y()+radius);//右边√
        updateBottomRightCornerStylePath(startPoint,endPoint,radius,"TopLeftCornerStyle",path);//右下角√

        path.closeSubpath();//下边√
    }
    //若上边平移至下边之下（sizePoint在相对于positionPoint的第四象限）
    else if(positionPoint.x()<sizePoint.x()&&positionPoint.y()>sizePoint.y())
    {
        startPoint=QPointF(sizePoint.x(),positionPoint.y());
        endPoint=QPointF(positionPoint.x(),sizePoint.y());

        BottomLeftCornerStyle = p_TopLeftCornerStyle;
        TopLeftCornerStyle = p_BottomLeftCornerStyle;
        TopRightCornerStyle = p_BottomRightCornerStyle;
        BottomRightCornerStyle = p_TopRightCornerStyle;

        path.moveTo(endPoint.x()+radius,endPoint.y());//起点√
        updateBottomLeftCornerStylePath(startPoint,endPoint,radius,"TopLeftCornerStyle",path);//左下角√

        path.lineTo(endPoint.x(),startPoint.y()-radius);//左边√
        updateTopLeftCornerStylePath(startPoint,endPoint,radius,"BottomLeftCornerStyle",path);//左上角√

        path.lineTo(startPoint.x()-radius,startPoint.y());//上边√
        updateTopRightCornerStylePath(startPoint,endPoint,radius,"BottomRightCornerStyle",path);//右上角√

        path.lineTo(startPoint.x(),endPoint.y()+radius);//右边√
        updateBottomRightCornerStylePath(startPoint,endPoint,radius,"TopRightCornerStyle",path);//右下角√

        path.closeSubpath();//下边√
    }
    this->setPath(path);//开始绘制
}

void GY_GraphicsCornerStyleRect::initializationPropertyInfo()
{

    m_CornerStyleEnumToMap={
        {"INVERTED_ROUND",CornerStyle::INVERTED_ROUND},
        {"INVERTED_SQUARE",CornerStyle::INVERTED_SQUARE},
        {"MITER",CornerStyle::MITER},
        {"ROUND",CornerStyle::ROUND},
        {"SQUARE",CornerStyle::SQUARE}
    };    

    QPointF Position = QPointF(0,0);//开始的坐标或中心点坐标
    QPointF point1 = QPointF(1,1);//结束的坐标或径向梯度的焦点坐标
    QPointF point2 = QPointF(-1,-1);//结束的坐标或径向梯度的焦点坐标
    QVector<qreal> varGradientStyle;
    varGradientStyle<<Position.x()<<Position.y()<<point1.x()<<point1.y()<<point2.x()<<point2.y();

    GY_PropertyInfo ObjectName(this);
    ObjectName.propertyName = "ObjectName";
    ObjectName.propertyValue = QString();
    ObjectName.updateType = Update|OrdinaryAttributes;
    ObjectName.propertyType = QStringPropertyType;
    ObjectName.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateObjectName;
    m_PropertyInfoMap.insert("ObjectName",ObjectName);
    m_PropertyInfoMap["ObjectName"].setConnect();

    GY_PropertyInfo IsVisible(this);
    IsVisible.propertyName = "IsVisible";
    IsVisible.propertyValue = true;
    IsVisible.updateType = Update|OrdinaryAttributes;
    IsVisible.propertyType = BoolPropertyType;
    IsVisible.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateIsVisible;
    m_PropertyInfoMap.insert("IsVisible",IsVisible);
    m_PropertyInfoMap["IsVisible"].setConnect();

    GY_PropertyInfo IsOutLined(this);
    IsOutLined.propertyName = "IsOutlined";
    IsOutLined.propertyValue = true;
    IsOutLined.updateType = Update|OrdinaryAttributes;
    IsOutLined.propertyType = BoolPropertyType;
    IsOutLined.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateIsOutLined;
    m_PropertyInfoMap.insert("IsOutlined",IsOutLined);
    m_PropertyInfoMap["IsOutlined"].setConnect();

    GY_PropertyInfo IsFilled(this);
    IsFilled.propertyName = "IsFilled";
    IsFilled.propertyValue = true;
    IsFilled.updateType = Update|OrdinaryAttributes;
    IsFilled.propertyType = BoolPropertyType;
    IsFilled.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateIsFilled;
    m_PropertyInfoMap.insert("IsFilled",IsFilled);
    m_PropertyInfoMap["IsFilled"].setConnect();

    GY_PropertyInfo IsAntialiased(this);
    IsAntialiased.propertyName = "IsAntialiased";
    IsAntialiased.propertyValue = true;
    IsAntialiased.updateType = Update|OrdinaryAttributes;
    IsAntialiased.propertyType = BoolPropertyType;
    IsAntialiased.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateIsAntialiased;
    m_PropertyInfoMap.insert("IsAntialiased",IsAntialiased);
    m_PropertyInfoMap["IsAntialiased"].setConnect();

    GY_PropertyInfo FillAttributes(this);
    FillAttributes.propertyName = "FillAttributes";
    FillAttributes.propertyValue = false;
    FillAttributes.updateType = Update|OrdinaryAttributes;
    FillAttributes.propertyType = BoolPropertyType;
    FillAttributes.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateFillAttributes;
    m_PropertyInfoMap.insert("FillAttributes",FillAttributes);
    m_PropertyInfoMap["FillAttributes"].setConnect();

    GY_PropertyInfo FillStyle(this);
    FillStyle.propertyName = "FillStyle";
    FillStyle.propertyValue = false;
    FillStyle.updateType = Update|OrdinaryAttributes;
    FillStyle.propertyType = FillStylePropertyType;
    FillStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateFillStyle;
    m_PropertyInfoMap.insert("FillStyle",FillStyle);
    m_PropertyInfoMap["FillStyle"].setConnect();

    GY_PropertyInfo FillColor(this);
    FillColor.propertyName = "FillColor";
    FillColor.propertyValue = QColor();
    FillColor.updateType = Update|OrdinaryAttributes;
    FillColor.propertyType = ColorPropertyType;
    FillColor.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateFillColor;
    m_PropertyInfoMap.insert("FillColor",FillColor);
    m_PropertyInfoMap["FillColor"].setConnect();

    GY_PropertyInfo FillGradient(this);
    FillGradient.propertyName = "FillGradient";
    FillGradient.propertyValue = QVariant::fromValue(varGradientStyle);
    FillGradient.updateType = Update|OrdinaryAttributes;
    FillGradient.propertyType = FillGradientPropertyType;
    FillGradient.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateFillGradient;
    m_PropertyInfoMap.insert("FillGradient",FillGradient);
    m_PropertyInfoMap["FillGradient"].setConnect();

    GY_PropertyInfo Pattern(this);
    Pattern.propertyName = "Pattern";
    Pattern.propertyValue = QVariant();
    Pattern.updateType = Update|OrdinaryAttributes;
    Pattern.propertyType = PatternPropertyType;
    Pattern.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updatePattern;
    m_PropertyInfoMap.insert("Pattern",Pattern);
    m_PropertyInfoMap["Pattern"].setConnect();

    GY_PropertyInfo FillOpacity(this);
    FillOpacity.propertyName = "FillOpacity";
    FillOpacity.propertyValue = qreal(1);
    FillOpacity.updateType = Update|OrdinaryAttributes;
    FillOpacity.propertyType = QrealPropertyType;
    FillOpacity.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateFillOpacity;
    m_PropertyInfoMap.insert("FillOpacity",FillOpacity);
    m_PropertyInfoMap["FillOpacity"].setConnect();

    GY_PropertyInfo PenAttributes(this);
    PenAttributes.propertyName = "PenAttributes";
    PenAttributes.propertyValue = false;
    PenAttributes.updateType = Update|OrdinaryAttributes;
    PenAttributes.propertyType = BoolPropertyType;
    PenAttributes.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updatePenAttributes;
    m_PropertyInfoMap.insert("PenAttributes",PenAttributes);
    m_PropertyInfoMap["PenAttributes"].setConnect();

    GY_PropertyInfo PenColor(this);
    PenColor.propertyName = "PenColor";
    PenColor.propertyValue = QColor(255,255,255);
    PenColor.updateType = Update|OrdinaryAttributes;
    PenColor.propertyType = ColorPropertyType;
    PenColor.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updatePenColor;
    m_PropertyInfoMap.insert("PenColor",PenColor);
    m_PropertyInfoMap["PenColor"].setConnect();

    GY_PropertyInfo LineStyle(this);
    LineStyle.propertyName = "LineStyle";
    QVector<qreal> lineStyle;
    int style = Qt::SquareCap|Qt::BevelJoin|Qt::CustomDashLine;
    lineStyle<<style<<2<<3<<4<<5<<6<<7;//自定义矩形线框样式
    LineStyle.propertyValue = QVariant::fromValue(lineStyle);
    LineStyle.updateType = Update|OrdinaryAttributes;
    LineStyle.propertyType = LineStylePropertyType;
    LineStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateLineStyle;
    m_PropertyInfoMap.insert("LineStyle",LineStyle);
    m_PropertyInfoMap["LineStyle"].setConnect();

    GY_PropertyInfo PenOpacity(this);
    PenOpacity.propertyName = "PenOpacity";
    PenOpacity.propertyValue = qreal(1);
    PenOpacity.updateType = Update|OrdinaryAttributes;
    PenOpacity.propertyType = QrealPropertyType;
    PenOpacity.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updatePenOpacity;
    m_PropertyInfoMap.insert("PenOpacity",PenOpacity);
    m_PropertyInfoMap["PenOpacity"].setConnect();

    GY_PropertyInfo positionPoint(this);
    positionPoint.propertyName="Position";
    positionPoint.propertyValue=QPointF(0,0);
    positionPoint.updateType = Update|MoveUpdate|PointOfRelative;
    positionPoint.propertyType = PointPropertyType;
    positionPoint.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updatePositionPoint;
    m_PropertyInfoMap.insert("Position",positionPoint);
    m_PropertyInfoMap["Position"].setConnect();

    GY_PropertyInfo sizePoint(this);
    sizePoint.propertyName="Size";
    sizePoint.propertyValue=QPointF(100.0,50.0);
    sizePoint.updateType = Update|PointOfRelative;
    sizePoint.propertyType = PointPropertyType;
    sizePoint.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateSizePoint;
    m_PropertyInfoMap.insert("Size",sizePoint);
    m_PropertyInfoMap["Size"].setConnect();

    GY_PropertyInfo cornerRadius(this);
    cornerRadius.propertyName="CornerRadius";
    cornerRadius.propertyValue=qreal(10.0);
    cornerRadius.updateType = Update|OrdinaryAttributes;
    cornerRadius.propertyType = QrealPropertyType;
    cornerRadius.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateCornerRadius;
    m_PropertyInfoMap.insert("CornerRadius",cornerRadius);
    m_PropertyInfoMap["CornerRadius"].setConnect();

    GY_PropertyInfo p_BottomLeftCornerStyle(this);
    p_BottomLeftCornerStyle.propertyName = "BottomLeftCornerStyle";
    p_BottomLeftCornerStyle.propertyValue = QString("ROUND");
    p_BottomLeftCornerStyle.updateType = Update|OrdinaryAttributes;
    p_BottomLeftCornerStyle.propertyType = QStringPropertyType;
    p_BottomLeftCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateBottomLeftCornerStyle;
    m_PropertyInfoMap.insert("BottomLeftCornerStyle",p_BottomLeftCornerStyle);
    m_PropertyInfoMap["BottomLeftCornerStyle"].setConnect();

    GY_PropertyInfo p_TopLeftCornerStyle(this);
    p_TopLeftCornerStyle.propertyName = "TopLeftCornerStyle";
    p_TopLeftCornerStyle.propertyValue = QString("ROUND");
    p_TopLeftCornerStyle.updateType = Update|OrdinaryAttributes;
    p_TopLeftCornerStyle.propertyType = QStringPropertyType;
    p_TopLeftCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateTopLeftCornerStyle;
    m_PropertyInfoMap.insert("TopLeftCornerStyle",p_TopLeftCornerStyle);
    m_PropertyInfoMap["TopLeftCornerStyle"].setConnect();

    GY_PropertyInfo p_TopRightCornerStyle(this);
    p_TopRightCornerStyle.propertyName = "TopRightCornerStyle";
    p_TopRightCornerStyle.propertyValue = QString("ROUND");
    p_TopRightCornerStyle.updateType = Update|OrdinaryAttributes;
    p_TopRightCornerStyle.propertyType = QStringPropertyType;
    p_TopRightCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateTopRightCornerStyle;
    m_PropertyInfoMap.insert("TopRightCornerStyle",p_TopRightCornerStyle);
    m_PropertyInfoMap["TopRightCornerStyle"].setConnect();

    GY_PropertyInfo p_BottomRightCornerStyle(this);
    p_BottomRightCornerStyle.propertyName = "BottomRightCornerStyle";
    p_BottomRightCornerStyle.propertyValue = QString("ROUND");
    p_BottomRightCornerStyle.updateType = Update|OrdinaryAttributes;
    p_BottomRightCornerStyle.propertyType = QStringPropertyType;
    p_BottomRightCornerStyle.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_GraphicsCornerStyleRect::updateBottomRightCornerStyle;
    m_PropertyInfoMap.insert("BottomRightCornerStyle",p_BottomRightCornerStyle);
    m_PropertyInfoMap["BottomRightCornerStyle"].setConnect();
}
